home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / AppleShare API / PowerPC AppleShare API / PPC UGLibrary / PPCUGLibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-12  |  4.3 KB  |  159 lines  |  [TEXT/MPS ]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    Glue to call UGLibrary in a code resource from a PPC application
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support
  7. **
  8. **    File:        PPCUGLibrary.c
  9. **
  10. **    Copyright © 1995 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  17. **    after having made changes. If you're going to re-distribute the source,
  18. **    we require that you make it clear in the source that the code was
  19. **    descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #include <Memory.h>
  23. #include <Resources.h>
  24. #include "UGLibraryGlue.h"
  25.  
  26. static    UGEntryPoints    gUGEntryPoints;
  27. static    Handle            gUGLibraryHandle = NULL; /* initially set to NULL */
  28.  
  29. /*
  30. **    Load the UGLibrary code resource and then initialize gUGEntryPoints.
  31. */
  32. static    OSErr    LoadUGLibrary(void)
  33. {
  34.     OSErr    result = noErr;
  35.     
  36.     /* If the UGLibrary code isn't loaded, load it now. */
  37.     if ( gUGLibraryHandle == NULL )
  38.     {
  39.         gUGLibraryHandle = Get1Resource(kUGLibraryResType, kUGLibraryResID);
  40.         if ( gUGLibraryHandle != NULL )
  41.         {
  42.             /*
  43.             **    IMPORTANT NOTE: The stand-alone code resource is has the
  44.             **    PRELOAD and LOCKED attributes set so I don't lock it here.
  45.             */
  46.             
  47.             /* Set up the entry points structure */
  48.             CallUniversalProc((UniversalProcPtr)*gUGLibraryHandle,
  49.                               uppMainEntryProcInfo, &gUGEntryPoints);
  50.         }
  51.         else
  52.         {
  53.             result = ResError();
  54.         }
  55.     }
  56.     return ( result );
  57. }
  58.  
  59. /*
  60. **    One routine for each defined in UGLibrary.h
  61. **    Each routine calls the appropriate UGLibrary function.
  62. **
  63. **    WARNING:    UGOpenFile must be called from this code so that 
  64. **                LoadUGLibrary is called to load the stand-alone
  65. **                code resource and initialize gUGEntryPoints.
  66. */
  67.  
  68. pascal OSErr    UGOpenFile(UserGroupPBPtr thePB, Boolean async)
  69. {
  70.     OSErr    result;
  71.     
  72.     result = LoadUGLibrary();
  73.     if ( result == noErr )
  74.     {
  75.         result = CallUGProc(gUGEntryPoints.UGOpenFile, thePB, async);
  76.     }
  77.     return ( result );
  78. }
  79.  
  80. pascal OSErr    UGCloseFile(UserGroupPBPtr thePB, Boolean async)
  81. {
  82.     return ( CallUGProc(gUGEntryPoints.UGCloseFile, thePB, async) );
  83. }
  84.  
  85. pascal OSErr    UGCreateFile(UserGroupPBPtr thePB, Boolean async)
  86. {
  87.     return ( CallUGProc(gUGEntryPoints.UGCreateFile, thePB, async) );
  88. }
  89.  
  90. pascal OSErr    UGNewUser(UserGroupPBPtr thePB, Boolean async)
  91. {
  92.     return ( CallUGProc(gUGEntryPoints.UGNewUser, thePB, async) );
  93. }
  94.  
  95. pascal OSErr    UGDeleteUser(UserGroupPBPtr thePB, Boolean async)
  96. {
  97.     return ( CallUGProc(gUGEntryPoints.UGDeleteUser, thePB, async) );
  98. }
  99.  
  100. pascal OSErr    UGRenameUser(UserGroupPBPtr thePB, Boolean async)
  101. {
  102.     return ( CallUGProc(gUGEntryPoints.UGRenameUser, thePB, async) );
  103. }
  104.  
  105. pascal OSErr    UGGetUserInfo(UserGroupPBPtr thePB, Boolean async)
  106. {
  107.     return ( CallUGProc(gUGEntryPoints.UGGetUserInfo, thePB, async) );
  108. }
  109.  
  110. pascal OSErr    UGSetUserInfo(UserGroupPBPtr thePB, Boolean async)
  111. {
  112.     return ( CallUGProc(gUGEntryPoints.UGSetUserInfo, thePB, async) );
  113. }
  114.  
  115. pascal OSErr    UGAuthenticateUser(UserGroupPBPtr thePB, Boolean async)
  116. {
  117.     return ( CallUGProc(gUGEntryPoints.UGAuthenticateUser, thePB, async) );
  118. }
  119.  
  120. pascal OSErr    UGNewGroup(UserGroupPBPtr thePB, Boolean async)
  121. {
  122.     return ( CallUGProc(gUGEntryPoints.UGNewGroup, thePB, async) );
  123. }
  124.  
  125. pascal OSErr    UGDeleteGroup(UserGroupPBPtr thePB, Boolean async)
  126. {
  127.     return ( CallUGProc(gUGEntryPoints.UGDeleteGroup, thePB, async) );
  128. }
  129.  
  130. pascal OSErr    UGRenameGroup(UserGroupPBPtr thePB, Boolean async)
  131. {
  132.     return ( CallUGProc(gUGEntryPoints.UGRenameGroup, thePB, async) );
  133. }
  134.  
  135. pascal OSErr    UGGetGroupInfo(UserGroupPBPtr thePB, Boolean async)
  136. {
  137.     return ( CallUGProc(gUGEntryPoints.UGGetGroupInfo, thePB, async) );
  138. }
  139.  
  140. pascal OSErr    UGAssignUserToGroup(UserGroupPBPtr thePB, Boolean async)
  141. {
  142.     return ( CallUGProc(gUGEntryPoints.UGAssignUserToGroup, thePB, async) );
  143. }
  144.  
  145. pascal OSErr    UGDeleteUserFromGroup(UserGroupPBPtr thePB, Boolean async)
  146. {
  147.     return ( CallUGProc(gUGEntryPoints.UGDeleteUserFromGroup, thePB, async) );
  148. }
  149.  
  150. pascal OSErr    UGGetULInfo(UserGroupPBPtr thePB, Boolean async)
  151. {
  152.     return ( CallUGProc(gUGEntryPoints.UGGetULInfo, thePB, async) );
  153. }
  154.  
  155. pascal OSErr    UGSetULInfo(UserGroupPBPtr thePB, Boolean async)
  156. {
  157.     return ( CallUGProc(gUGEntryPoints.UGSetULInfo, thePB, async) );
  158. }
  159.